package com.jdbc.dao;

import com.jdbc.entity.Dog;

import java.util.List;

/**
 * @author wzm
 * @create 2023-04-11 14:47
 */
public class BaseDaoTest {
    public static void main(String[] args) {
        BaseDao baseDao = new BaseDao();

        //测试新增
        //String sql = "insert into dog values(?,?,?,?,?)";
        //测试删除
       // String sql = "delete from dog where id = ?";
       /* String sql = "update dog set name = ?,age = ?,sex = ?,typeid = ? where id = ?";


        int update = baseDao.update(sql, "11111",5,"母",2,7);
        if(update > 0){
            System.out.println("成功");
        }else{
            System.out.println("失败");
        }*/
        
        //测试查询单个对象
//        String sql = "select * from dog where id = ?";
//        Dog dog = baseDao.selectForOne(Dog.class, sql, 1);
//        System.out.println("dog = " + dog);
        
        //测试查询全部对象
       /* String sql = "select * from dog";
        List<Dog> dogs = baseDao.selectForList(Dog.class, sql);
        System.out.println("dogs = " + dogs);*/
        
        String sql = "select count(*) from dog";
        Number number = (Number) baseDao.selectForValue(sql);
        int i = number.intValue();
        System.out.println("i = " + i);


    }
}
